Button 4 Click
Button 4 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Mar 2025.
- Type : GPIO type
Software Support
Example Description
This example demonstrates the use of the Button 4 Click board by initializing the device and detecting the button state changes. It logs whether the button is pressed (active) or released (reset).
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Button4
Example Key Functions
- button4_cfg_setup This function initializes Click configuration structure to initial values.
- button4_init This function initializes all necessary pins and peripherals used for this Click board.
- button4_get_out_pin This function returns the OUT pin logic state.
Application Init
Initializes the logger and the Button 4 Click driver.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( DIGITAL_OUT_UNSUPPORTED_PIN ==
button4_init( &button4, &button4_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
void application_init(void)
Definition main.c:34
#define MIKROBUS_POSITION_BUTTON4
Definition main.c:28
Application Task
Monitors the button state and logs whether the button is active (pressed) or reset (released) when a state change is detected.
{
if ( button_state_old != button_state )
{
button_state_old = button_state;
{
log_printf ( &logger, " BUTTON ACTIVE\r\n\n" );
}
else
{
log_printf ( &logger, " BUTTON RESET\r\n\n" );
}
}
}
void application_task(void)
Definition main.c:64
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.